package com.ldf.media.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

import com.ldf.media.websocket.WebRTCWebSocketHandler;

@Configuration
@EnableWebSocket
public class WebsocketConfig implements WebSocketConfigurer {
    
    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        // 注册WebRTC信令处理WebSocket端点
//        registry.addHandler(new WebRTCWebSocketHandler(), "/webrtc")
//                .setAllowedOrigins("*")
//                .allowCredentials(false); // 根据需求设置是否允许凭据
//
//        // 启用跨域支持
//        registry.setApplicationDestinationPrefixes("/app");
//        registry.addCorsMappings("/webrtc/**")
//                .setAllowedOrigins("*")
//                .setAllowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
//                .setAllowedHeaders("Content-Type", "Authorization")
//                .setAllowCredentials(false); // 根据需求设置是否允许凭据
    }
}